<h1 class="text-2xl font-bold"><%= @torrent.name %></h1>

<div class="mb-4">
  <p>
    <span class="font-bold">Filesize:</span>
    <span><%= @torrent.size_in_bytes |> Size.humanize!() %></span>
  </p>
  <p>
    <span class="font-bold">Published at:</span>
    <span><%= @torrent.published_at |> Calendar.strftime("%B %-d, %Y - %I:%M:%S %p %Z") %></span>
  </p>
  <p>
    <span class="font-bold">Category:</span>
    <span><%= @torrent.category.name %></span>
  </p>
  <p>
    <span class="font-bold">Source:</span>
    <span>
      <.link
        href={@torrent.canonical_url}
        target="_blank"
        title="Visit the canonical url for this torrent."
        class="text-blue-500 hover:underline"
      >
        <%= @torrent.source.name %>
      </.link>
    </span>
  </p>
</div>

<div class="flex items-center">
  <.link
    href={{:magnet, @torrent.magnet_url}}
    class="mr-4 inline-flex items-center text-white bg-gradient-to-br from-purple-600 to-blue-500 hover:bg-gradient-to-bl focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center"
  >
    <span class="mr-4">Magnet Download</span>
    <svg
      xmlns="http://www.w3.org/2000/svg"
      fill="none"
      viewBox="0 0 24 24"
      stroke-width="1.5"
      stroke="currentColor"
      class="w-6 h-6"
    >
      <path
        stroke-linecap="round"
        stroke-linejoin="round"
        d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
      />
    </svg>
  </.link>
  <span class="inline-flex flex-col items-center mr-4">
    <span>Seeders</span>
    <span class="ml-1 text-sm font-bold text-green-500"><%= @torrent.seeders %></span>
  </span>

  <span class="inline-flex flex-col items-center">
    <span>Leechers</span>
    <span class="ml-1 text-sm font-bold text-red-500"><%= @torrent.leechers %></span>
  </span>
</div>

<hr class="my-8 border-black/10" />

<div class="prose">
  <h2 class="text-lg font-bold">Description</h2>
  <%= if @torrent.description do %>
    <%= Earmark.as_html!(@torrent.description)
    |> HtmlSanitizeEx.markdown_html()
    |> Phoenix.HTML.raw() %>
  <% else %>
    <p>No description found on crawler site.</p>
  <% end %>
</div>
